/*
 * Team Name: Team Sasquatch
 * Cody Sharff
 * Anthony Rios
 * Prince Kishore
 * Travis Drake
 */

package gui;

import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * A frame with dimensions 800, 600.
 * 
 * @author Anthony Rios
 * 
 * @version 05/27/2012
 */
@SuppressWarnings("serial")
public class MainFrame extends JFrame implements WindowListener {

    MasterGUI my_master_gui;
    
	/**
	 * Constructs the frame and sets the default title of Calendar.
	 */
	public MainFrame(MasterGUI the_master_gui) {
		setPreferredSize(new Dimension(800, 600));
		setTitle("Calendar");
		pack();
		my_master_gui = the_master_gui;
		addWindowListener(this);
	}
	
	public void start() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    setVisible(true);
	}
	
	/**
	 * Sets a panel in the frame to be displayed.
	 */
	public void setPanel(JPanel the_panel) {
		setContentPane(the_panel);
		pack();
	}

    /**
     * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
     */
    @Override
    public void windowActivated(WindowEvent e)
    {
    }

    /**
     * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
     */
    @Override
    public void windowClosed(WindowEvent e)
    {
        System.out.println("Window Closed");
        my_master_gui.finalizeData();
    }

    /**
     * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
     */
    @Override
    public void windowClosing(WindowEvent e)
    {
        System.out.println("Window Closing");
        my_master_gui.finalizeData();
        
    }

    /**
     * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
     */
    @Override
    public void windowDeactivated(WindowEvent e)
    {
        
        
    }

    /**
     * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
     */
    @Override
    public void windowDeiconified(WindowEvent e)
    {
        
        
    }

    /**
     * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
     */
    @Override
    public void windowIconified(WindowEvent e)
    {
        
        
    }

    /**
     * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
     */
    @Override
    public void windowOpened(WindowEvent e)
    {
        
        
    }
}
